package com.edwarder.action;

import com.edwarder.entity.City;
import com.edwarder.service.CityService;
import com.edwarder.service.impl.CityServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.sound.midi.Soundbank;
import java.io.IOException;
import java.util.List;

/**
 * @Auther: jzhang
 * @Date: 2018/9/21 15:04
 * @Description:
 */
@WebServlet("/city/list")
public class CityAction extends HttpServlet {
    private CityService cityService = new CityServiceImpl();

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //设置编码
        response.setContentType("text/html;charset=utf-8");
        String provinceId = request.getParameter("provinceId");
        String cityString = cityService.getCityJSONString(provinceId);
        response.getWriter().println(cityString);
    }

}
